package com.tunisair.app.entities;

import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Email;

@Entity
@Table(name="USERS")
public class User {
	@Id
	private String matricule;
	
	@Column(nullable = false)
	@Size(min=3)
	private String nom;
	
	@Column(nullable = false)
	@Size(min=3)
	private String prenom;
	
	@Email
	@Column(nullable = false)
	private String email;
	
	@Column(unique = true, nullable = false)
	private String username;
	
	@Size(min=8)
	@Column(nullable = false)
	private String password;

	@Column(nullable = false,columnDefinition = "boolean default true")
	private boolean actived;
	
	@OneToMany
	@JoinColumn(name="user_id")
	private Collection<Role> roles;
	
	@OneToMany
	@JoinColumn(name="user_id")
	private Collection<Autorisation> autorisations;

	public String getMatricule() {
		return matricule;
	}

	public void setMatricule(String matricule) {
		this.matricule = matricule;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public boolean isActived() {
		return actived;
	}

	public void setActived(boolean actived) {
		this.actived = actived;
	}

	public Collection<Role> getRoles() {
		return roles;
	}

	public void setRoles(Collection<Role> roles) {
		this.roles = roles;
	}

	public Collection<Autorisation> getAutorisations() {
		return autorisations;
	}

	public void setAutorisations(Collection<Autorisation> autorisations) {
		this.autorisations = autorisations;
	}

	public User(String matricule, String nom, String prenom, String email,
			String username, String password) {
		super();
		this.matricule = matricule;
		this.nom = nom;
		this.prenom = prenom;
		this.email = email;
		this.username = username;
		this.password = password;
	}

	public User() {
		super();
		// TODO Auto-generated constructor stub
	}
	
	
	
	
	
}
